﻿using FunArts.EasyDevOps.Shared.Models.SshClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FunArts.EasyDevOps.Rcl.ViewModels
{
    public class DirectoryNodeViewModel
    {
        public DirectoryNode directoryNode { get; set; }

        public DirectoryNode FindDirectoryNode(string fullName)
        {
            if (directoryNode == null)
                return null;
            if (directoryNode.FullPath == fullName)
                return directoryNode;
            return FindDirectoryNode(fullName, directoryNode.Children);
        }

        public DirectoryNode FindDirectoryNode(string fullName, List<DirectoryNode> Children)
        {
            if (Children == null)
                return null;
            foreach (var item in Children)
            {
                if (item.FullPath == fullName)
                    return item;
                DirectoryNode directoryNode= FindDirectoryNode(fullName, item.Children);
                if (directoryNode != null)
                    return directoryNode;
            }
            return null;
        }
    }
}
